Skip to content

Add DatastoreMigration CR awareness to operator controllers#4577

Merged
caseydavenport merged 6 commits intotigera:masterfrom
caseydavenport:casey-migration-cr-support
Mar 26, 2026
Merged

Add DatastoreMigration CR awareness to operator controllers#4577
caseydavenport merged 6 commits intotigera:masterfrom
caseydavenport:casey-migration-cr-support

Conversation

@caseydavenport
Copy link
Copy Markdown
Member

Wire up the operator to read DatastoreMigration CRs and react to migration phase changes:

  • Defer APIServer reconciliation during Migrating phase to avoid fighting over the APIService resource
  • Trigger operator restart on Converged phase to switch to v3 CRD mode
  • Create/delete dynamic migration RBAC (calico-kube-controllers-migration ClusterRole) based on whether a DatastoreMigration CR exists
  • Check DatastoreMigration CR at startup to handle operator restarts during or after migration
  • Change UseV3CRDS() signature to accept *rest.Config so it can create a dynamic client for the DatastoreMigration check

Stacked on #4576 -- merge that first.

Wire up the operator to read DatastoreMigration CRs and react to
migration phase changes:

- Defer APIServer reconciliation during Migrating phase to avoid
  fighting over the APIService resource
- Trigger operator restart on Converged phase to switch to v3 CRD mode
- Create/delete dynamic migration RBAC for kube-controllers based on
  whether a DatastoreMigration CR exists
- Check DatastoreMigration CR at startup to handle operator restarts
  during or after migration
@caseydavenport caseydavenport force-pushed the casey-migration-cr-support branch from 51acfe6 to 09bb287 Compare March 24, 2026 15:50
- Return errors from GetPhase/Exists so callers can distinguish
  transient failures from "no migration CR exists"
- Accept context.Context in WaitForWatchAndAdd for clean shutdown
- Fix setAPIGroupEnvVar to handle multi-container pods correctly
- Move DatastoreMigrationGVR into datastoremigration package and
  have version.go call GetPhase directly, eliminating duplicated
  phase-checking logic
- Derive GVK from GVR in WaitForWatchAndAdd instead of inline literals
- Add comment noting migration RBAC is time-bounded
Comment thread pkg/controller/installation/core_controller.go Outdated
Replace dynamic client with a controller-runtime cached client for
DatastoreMigration CR lookups. Add minimal stub types registered with
the scheme so the manager's cache can watch these objects, and gate
queries on watch readiness to avoid uncached API server requests.
The UseV3CRDS check runs before the manager cache is started, so it
needs a direct dynamic client query rather than the cached client.
@caseydavenport caseydavenport merged commit 63641ec into tigera:master Mar 26, 2026
6 checks passed
@caseydavenport caseydavenport deleted the casey-migration-cr-support branch March 26, 2026 16:21
caseydavenport added a commit to caseydavenport/operator that referenced this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants